package cn.yunhe.servlet;

import cn.yunhe.service.ProductCategoryService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/DelCategoryServlet")
public class DelCategoryServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int epcid = Integer.parseInt(request.getParameter("epcid"));
        ProductCategoryService pcs = new ProductCategoryService();
        boolean b = pcs.deleteCategory(epcid);
        if(b){
            response.sendRedirect("manage/manage-result.jsp");
        }else {
            response.sendRedirect("manage/index.jsp");
        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
